#!/bin/sh
# EPICMU launcher - one download for every Mac.
#
# LaunchServices runs this script as the bundle's executable (no Terminal window), and it hands over
# to the binary for this machine. sysctl.proc_translated is 1 when we are the ones running under
# Rosetta, in which case uname says x86_64 on a machine that is really Apple silicon - then the
# arm64 binary is the right one and the player never sees a Rosetta prompt.
dir=$(cd "$(dirname "$0")" && pwd)
arch=$(uname -m)
if [ "$arch" = "x86_64" ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = "1" ]; then
    arch=arm64
fi
case "$arch" in
    arm64|aarch64) bin="$dir/Launcher-arm64"; other="$dir/Launcher-x64" ;;
    *)             bin="$dir/Launcher-x64";   other="$dir/Launcher-arm64" ;;
esac
# An archive unpacked by something that drops mode bits would leave these unrunnable.
[ -f "$bin" ] || bin="$other"
[ -x "$bin" ] || chmod +x "$bin" 2>/dev/null
exec "$bin" "$@"